<?php

namespace App\Admin\Service;

use App\Admin\Grid\NGrid;
use App\Models\PaymentModel;
use Encore\Admin\Grid\Filter;
use Encore\Admin\Show;

class PaymentService extends BaseService
{
    public string $table = 'payment';

    /**
     * grid
     * @return void
     */
    public function grid(): void
    {
        $this->grid = new NGrid(new PaymentModel);
        $this->grid->model()->orderByDesc('id');
        $this->filter();
        $this->gid();
    }

    /**
     * filter
     * @return void
     */
    public function filter(): void
    {
        $this->grid->filter(function (Filter $filter) {
            $filter->disableIdFilter();
            $filter->column(1 / 2, function (Filter $filter) {
                $filter->equal('id', 'ID')->integer();
            });
            $filter->column(1 / 2, function (Filter $filter) {
                $filter->equal('serial_number', $this->l['serialNumber']);
            });
        });
    }

    /**
     * show
     * @param int $id
     * @return void
     */
    public function show(int $id): void
    {
        parent::show($id);
        $this->show = new Show(PaymentModel::findOrFail($id));
        $this->sid();
    }
}
